.TH std::basic_string::end, 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::basic_string::end, \- std::basic_string::end,

.SH Synopsis

   iterator end();                       \fB(1)\fP (noexcept since C++11)
                                             (constexpr since C++20)
   const_iterator end() const;           \fB(2)\fP (noexcept since C++11)
                                             (constexpr since C++20)
   const_iterator cend() const noexcept; \fB(3)\fP \fI(since C++11)\fP
                                             (constexpr since C++20)

   Returns an iterator to the character following the last character of the string.
   This character acts as a placeholder, attempting to access it results in undefined
   behavior.

   range-begin-end.svg

.SH Parameters

   \fI(none)\fP

.SH Return value

   Iterator to the character following the last character.

.SH Complexity

   Constant.

.SH Notes

   libc++ backports cend() to C++98 mode.

.SH Example


// Run this code

 #include <algorithm>
 #include <iostream>
 #include <iterator>
 #include <string>

 int main()
 {
     std::string s("Exemparl");
     std::next_permutation(s.begin(), s.end());

     std::string c;
     std::copy(s.cbegin(), s.cend(), std::back_inserter(c));
     std::cout << c << '\\n'; // "Exemplar"
 }

.SH Output:

 Exemplar

.SH See also

   begin   returns an iterator to the beginning
   cbegin  \fI(public member function)\fP
   \fI(C++11)\fP
   end     returns an iterator to the end
   cend    \fI(public member function of std::basic_string_view<CharT,Traits>)\fP
